/**
 * Created by limeng on 16/9/1.
 */
indexApp.controller("HistoryListCtrl", function ($scope, $http) {
    $scope.title = "历年提案";

    $scope.pageSize = 10;
    $scope.pageNo = 1;
    $scope.inputPageNo = 1;
    $scope.pageCount = 1;
    $scope.configs = [];

    $scope.updateContent = function() {
        $http.get('/systemConfig/history/'+
            parseInt($scope.pageSize)+"/"+parseInt($scope.pageNo)).success(
            function (data) {
                if (data.state == true) {
                    $scope.configs = data.list;
                    $scope.pageCount = data.pageCount;
                }
        });
    };

    $scope.previousPage = function () {
        $scope.pageNo = ($scope.pageNo - 1) < 1 ? 1 : --$scope.pageNo;
        $scope.updateContent();
    };
    $scope.nextPage = function() {
        $scope.pageNo = ($scope.pageNo + 1) >= $scope.pageCount ? $scope.pageCount : ++$scope.pageNo;
        $scope.updateContent();
    };
    $scope.jumpPage = function () {
        if ($scope.inputPageNo > 0 && $scope.inputPageNo <= $scope.pageCount) {
            $scope.pageNo = parseInt($scope.inputPageNo);
            $scope.updateContent();
        } else {
            $scope.inputPageNo = 1;
        }
    };

    $(".nav_elem").removeClass("jc_li_selected");
    $("#nav_history").addClass("jc_li_selected");

    $scope.updateContent();
});